﻿using System.Collections.Generic;
using Fetches.Fetch.Dto;

namespace Fetches.Fetch.Factory.Persistence
{
    public interface IRuntimeDataService
    {
        #region Factory设置

        FactoryConfig ReadFactoryConfig();

        void WriteFactoryConfig(FactoryConfig config);

        void Rebuild();
        #endregion

        #region 多FacotryUnit的情况下调度信息
        /// <summary>
        /// 还没想好LocalFactory怎么利用这个信息
        /// </summary>
        /// <returns></returns>
        IList<UnitSchedules> LoadAllUnitSchedules();

        /// <summary>
        /// 这个API主要FactoryUnit的Fetcher列表变化时调用
        /// </summary>
        /// <param name="schedules"></param>
        void UpdateWorkshopScheduleData(UnitSchedules schedules);

        #endregion

        #region Fetch任务相关

        /// <summary>
        ///     运行数据里只需要加载未完成任务，已完成的自行从其他地方获取
        /// </summary>
        /// <returns></returns>
        IList<FetchTask> LoadUnfinishedFetchTask();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="taskId"></param>
        /// <returns></returns>
        FetchTask GetFetchTaskByTaskId(long taskId);

        /// <summary>
        /// 调度以FetcherId为单位，所以要提供直接从fetcherId反推FetchTask的方法
        /// </summary>
        /// <param name="fetcherId"></param>
        /// <returns></returns>
        FetchTask GetFetchTaskByFetcherId(long fetcherId);

        /// <summary>
        ///     登记或更新任务信息
        /// </summary>
        /// <param name="task"></param>
        void RegisterOrUpdateFetchTask(FetchTask task);

        /// <summary>
        ///     更新task状态，内部决定到底是删除还是怎么操作
        /// </summary>
        /// <param name="taskId"></param>
        /// <param name="status"></param>
        void UpdateFetchTaskStatus(long taskId, FetchTaskStatus status);

        #endregion
    }
}